package app.netant.book.xiami77;

import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import app.netant.book.base.BaseDetail;
import app.netant.book.base.BaseEntity;
import app.netant.book.base.BasePage;
import cn.lily.com.enviroment.Enviroment;

public class Xiami77Page extends BasePage {

	public Xiami77Page(String netSite) {
		super(netSite);
		this.tableKey = "xiami77";
		this.selectKey = "table[border='0'][cellspacing='10'][cellpadding='0'] tbody tr td.list_content "
				       + "table[border='0'][cellspacing='0'][cellpadding='0'] tbody tr td "
				       + "table[border='0'][cellspacing='0'][cellpadding='0'] tbody tr td.down_list "
				       + "table[border='0'][cellspacing='1'][cellpadding='3'] tbody tr td[width='290'] b a";
		this.preHref = "https://www.xiami77.com";
	}

	@Override
	public String buildHref(Element element) {	
		String href = element.attr("href");
		if(href.startsWith("/")){
			href = this.preHref + href;
		}
		return href;
	}

	@Override
	public BaseEntity buildEntity() {
		return new Xiami77Entity();
	}

	@Override
	public BaseDetail buildDetail(String href) {
		return new Xiami77Detail(href);
	}

	@Override
	public void afterEntity(BaseEntity entity, Element element) {
		
	}
	
	public static void main(String[] args) {
		Enviroment.createEnv();
		Enviroment.getEnv().getLogBean().beginLog();
		Xiami77Page page = new Xiami77Page("https://www.xiami77.com/yq/");
		page.analyseHref();
	}
	
}
